Skip to content

Add Perplexity integration package#3262

Open
jliounis wants to merge 1 commit intodeepset-ai:mainfrom
jliounis:add-perplexity-search
Open

Add Perplexity integration package#3262
jliounis wants to merge 1 commit intodeepset-ai:mainfrom
jliounis:add-perplexity-search

Conversation

@jliounis
Copy link
Copy Markdown

Summary

Adds a new perplexity-haystack integration package providing a PerplexityWebSearch component that wraps the Perplexity Search API. Each search result is returned as a Haystack Document carrying the snippet content plus title/url/date metadata.

The package layout mirrors the existing tavily-haystack integration line-for-line — same pyproject.toml structure, same src/haystack_integrations/components/websearch/<provider>/ layout, same hatch test/lint scripts, same CI workflow shape.

  • HTTP via httpx (sync + async) — no third-party Perplexity SDK dependency
  • Auth via PERPLEXITY_API_KEY env var or Secret constructor argument
  • Sends an X-Pplx-Integration: haystack/<package-version> attribution header on every request
  • 17 unit tests with mocked HTTP (httpx.MockTransport) covering serialization, request shaping, header attribution, error paths and async behaviour

Testing

  • hatch run test:unit — 17 passed
  • hatch run test:unit-cov-retry — 95% line coverage
  • hatch run fmt-check
  • hatch run test:types (mypy clean)

Adds a new integration package providing a `PerplexityWebSearch`
component that wraps the Perplexity Search API, returning Haystack
Documents built from search result snippets, titles and URLs.

Mirrors the existing Tavily websearch integration in layout, lint
and test conventions.

Signed-off-by: james-pplx <james-pplx@users.noreply.github.com>
@jliounis jliounis requested a review from a team as a code owner April 30, 2026 14:52
@jliounis jliounis requested review from sjrl and removed request for a team April 30, 2026 14:52
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions Bot added topic:CI type:documentation Improvements or additions to documentation labels Apr 30, 2026
@sjrl
Copy link
Copy Markdown
Contributor

sjrl commented Apr 30, 2026

@jliounis thanks for opening the PR! It's looking in good shape. I'll be able to give it more in depth review next week.

If by then you could sign the CLA agreement #3262 (comment) that would be greatly appreciated.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is auto generated so please remove from this PR. Will be created after this PR is merged.

Comment on lines +53 to +55
def __init__(
self,
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We like to enforce keyword only in newly added components

Suggested change
def __init__(
self,
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),
def __init__(
self,
*,
api_key: Secret = Secret.from_env_var("PERPLEXITY_API_KEY"),

expected_type = "haystack_integrations.components.websearch.perplexity.perplexity_websearch.PerplexityWebSearch"
assert data["type"] == expected_type
assert data["init_parameters"]["top_k"] == 5
assert data["init_parameters"]["search_params"] == {"country": "US"}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's also add an assert to check the api_key was properly serialized

@sjrl sjrl self-assigned this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration:perplexity topic:CI type:documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants